package com.yao.util;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 使用Jsoup操作dom把前端传来的对应网站进行文章解析
 * @author 妖悲冥
 * @date 2021/6/3 0003   -    14:51
 */
@Component
public class ArticleExtraction {
    public List<Map<String,String>> setArticle(){
        List<Map<String,String>> mapList=new ArrayList<>();
        Document doc = null;
        try {
            doc = Jsoup.connect("https://finance.sina.com.cn//stock//stockzmt//2021-06-03//doc-ikqciyzi7471484.shtml").get();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Element body = doc.body();
        Elements title = body.select("h1.main-title");

        return mapList;
    }
}
